import { UserService } from './user.service';
import { Controller, Get, Post, Body, HttpCode, Query } from '@nestjs/common';
import { CreateUserDto } from './dto/create.dto';
import { get } from 'http';

@Controller('user')
export class UserController {
  constructor(private readonly userService: UserService) {}

  @Get()
  findAll() {
    return this.userService.findAll()
  }

  @Post()
  // @HttpCode(200)
  async createUser(@Body() data: CreateUserDto) {
    return await this.userService.createUser(data);
  }

  // 根据用户名模糊查找用户
  @Get('findByName')
  getUsersByName(@Query('username') username: string) {
    return this.userService.getUsersByName(username);
  }
}
